<#include "../layout/header.ftl"/>
<body class="bg-primary">
<div class="page page-login text-center">
    <div class="panel">
        <div class="panel-body">
            <div class="logo">
                <a href="#">ZK-ADMIN</a>
            </div>
            <form action="${ctx}/conf/login/doLogin">
                <div class="form-group">
                    <input type="text" class="form-control" placeholder="ID/帐号" name="username" id="username">
                </div>
                <div class="form-group">
                    <input type="password" class="form-control" placeholder="密码" name="password" id="password">
                </div>
                <span id="login_msg" style="color: red"></span>
                <button type="button" id="btn_login" class="btn btn-lg btn-primary btn-block">登录</button>
            </form>
        </div>
    </div>
    <footer class="page-copyright page-copyright-inverse">
        <p>WEBSITE BY WDD</p>
        <p>© 2018. All RIGHT RESERVED.</p>
    </footer>
</div>
</body>
<script type="text/javascript">
    $(function () {
        $("#btn_login").click(function () {
            var username = $("#username").val();
            if ($.trim(username) == '') {
                $("#login_msg").html("用户名不能为空");
            }
            var password = $("#password").val();
            if ($.trim(password) == '') {
                $("#login_msg").html("密码不能为空");
            }

            $.ajax({
                type: "post",
                url: "${ctx}/conf/login/doLogin",
                data: {username: $("#username").val(), password: $("#password").val()},
                dataType: "json",
                success: function (data) {
                    $("#login_msg").html(data.msg);
                    if (data.success){
                        setTimeout(function () {//两秒后跳转
                            window.location.href = '${ctx}/conf/node/list';
                        }, 1000);
                    }
                }
            });
        });
    });
</script>